const base_url = 'https://api-hmugo-web.itheima.net/api/public/v1';
let ajaxTimes = 0;
export const request = (config) => {
    ajaxTimes++;
    wx.showLoading({
        title: "加载中",
        mask: true,
    });
    return new Promise((resolve, reject) => {
        wx.request({
            url: base_url+config.url,
            method: config.method || 'GET',
            data: config.data || {},
            success: (result)=>{
                resolve(result)
            },
            fail: (err)=>{
                reject(err)
            },
            complete: ()=>{
                ajaxTimes--;
                if(ajaxTimes === 0){
                    wx.hideLoading();
                }
            }
        });
    })
}